package com.nuaa.utils;

import java.io.File;

import javax.servlet.http.HttpServletRequest;

/***
 * 该类用来处理上传文件
 * @author heaven
 *
 */
public class FileManager {
	/**服务器文件所在文件夹*/
	private static String dir;
	public FileManager(String dir){
		this.dir = dir;
	}
	/**
	 * 通过文件名删除文件
	 */
	public static boolean delByFileName(String fileName){
		if("".equals(fileName)||fileName.isEmpty()){
			return false;
		}
		String fullPath = dir+"/file/"+fileName;
		File file = new File(fullPath);
		try {
			if(file.exists()){
				file.delete();
				System.out.println("OK");
			}
			System.out.println(fullPath);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}
}
